/* ESPRESSIF MIT License
 * 
 * Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
 * 
 * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
 * it is free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "app_httpd.h"
#include "app_mdns.h"
#include "app_board.h"
#include "esp_log.h"
#include "sdkconfig.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/uart.h"

#include <stdio.h>
#include <string.h>
#include <memory.h>

#include "app_uart.h"

// uart_event_t uart_event;
// int uart_write_bytes(uart_port_t uart_num, const void* src, size_t size);

// static void testTask()
// {
//     // uint8_t* sendData = (uint8_t*) malloc(sizeof(uint8_t) * 13);

//     // sprintf((char *) sendData, "%s", "Hello world\n");
//     // uart_event.size = 13;
//     // uart_event.type = UART_DATA;

//     while (1)
//     {
//         // uart_write_bytes(UART_NUM_0, (void*)sendData, 13);
//         // xQueueSend(uart0_queue, &uart_event, portMAX_DELAY);
//         send_UART_Data(0x91);
//         vTaskDelay(500);
//     }
// }

// static const uint8_t SOFT_READY_MESSAGE[5] = {0x12, 0x13, 0x14, 0x15, 0x16};

void app_main()
{
    app_board_main();

    app_httpd_main();

    app_mdns_main();

    // uint8_t* sendData = (uint8_t*) malloc(sizeof(uint8_t) * 13);

    // sprintf((char *) sendData, "%s", "Hello world\n");
    // uart_event.size = 13;
    // uart_event.type = UART_DATA;

    // xTaskCreate(testTask, "uart_send_task", 2048, NULL, 5, NULL);

    // uart_write_bytes(UART_NUM_0, (void*)sendData, 13);

    ESP_LOGI("esp-cam Version",CONFIG_ESP_CAM_VERSION);    
}
